import request from '@/utils/request'

// 预约看房相关 API
export const appointmentsAPI = {
  // 创建预约
  create(data) {
    return request({
      url: '/api/appointments',
      method: 'post',
      data,
    })
  },

  // 获取用户的预约列表
  getUserAppointments(params = {}) {
    return request({
      url: '/api/appointments',
      method: 'get',
      params,
    })
  },

  // 获取预约详情
  detail(id) {
    return request({
      url: `/api/appointments/${id}`,
      method: 'get',
    })
  },

  // 更新预约状态
  updateStatus(id, status) {
    return request({
      url: `/api/appointments/${id}/status`,
      method: 'put',
      data: { status },
    })
  },

  // 取消预约
  cancel(id) {
    return request({
      url: `/api/appointments/${id}/cancel`,
      method: 'put',
    })
  },

  // 获取房源的预约列表（房东查看）
  getPropertyAppointments(propertyId, params = {}) {
    return request({
      url: `/api/properties/${propertyId}/appointments`,
      method: 'get',
      params,
    })
  },
}
